import OpenGL
import OpenGL.GL
import OpenGL.GLU
import OpenGL.GLUT
from OpenGL.GL import *
from OpenGL.GLU import *
from OpenGL.GLUT import *
import math
from math import *

looping=True


class Monster:
    x=y=z=0.6
    yaw=0.0
    pitch=0.0

player=Monster()

def kbd(a,b,c):
    global looping
    if a=='q':
        looping=False

def mouse(x,y):
    player.yaw+=x*0.01
    player.pitch+=y*0.01
    pass

def display():
    glClearColor(.4,.5,.6,1.0)
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
    glMatrixMode(GL_MODELVIEW)
    glLoadIdentity()
    gluLookAt(player.x,player.y,player.z,
              0,#player.x+cos(player.yaw)*cos(player.pitch),
              0,#player.y+sin(player.yaw)*cos(player.pitch),
              0,#player.z*sin(player.pitch),
              0,0,1)
    glBegin(GL_LINES)
    glColor3f(1,0,0)
    glVertex3f(0,0,0)
    glVertex3f(1,0,0)
    
    glColor3f(0,1,0)
    glVertex3f(0,0,0)
    glVertex3f(0,1,0)
    
    glColor3f(0,0,1)
    glVertex3f(0,0,0)
    glVertex3f(0,0,1)
    
    glEnd()
    glutSwapBuffers()

def main():
    glutInit()
    glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGBA|GLUT_DEPTH)
    glutCreateWindow('qwe')
    glutDisplayFunc(display)
    glutKeyboardFunc(kbd)
    glutPassiveMotionFunc(mouse)
    while(looping):
        glutMainLoopEvent()
    pass


main()
